package homework08;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class StreamTest {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("黄老邪");
        one.add("陈玄风");
        one.add("梅超风");
        one.add("陆乘风");
        one.add("曲灵风");
        one.add("武眠风");
        one.add("冯默风");
        one.add("罗玉风");
        List<String> two = new ArrayList<>();
        two.add("张三丰");
        two.add("宋远桥");
        two.add("俞莲舟");
        two.add("俞岱岩");
        two.add("张松溪");
        two.add("张翠山");
        two.add("殷梨亭");
        two.add("莫声谷");
        //第一个队伍只要名字为3个字的成员姓名
     // one.stream().filter(name->name.length()<=3).forEach(name -> System.out.println(name) );
        //第一个队伍筛选之后只要前3个人；
     //  one.stream().filter(name->name.length()<=3).limit(3).forEach(name-> System.out.println(name));
        //第二个队伍只要姓张的成员姓名；
    // two.stream().filter(name->name.startsWith("张")).forEach(s -> System.out.println(s));
        //第二个队伍筛选之后不要前2个人
   //     two.stream().filter(name->name.startsWith("张"))
      //         .skip(2).forEach(s -> System.out.println(s));
        //将两个队伍合并为一个队伍；
       Stream<String> concat = Stream.concat(one.stream(), two.stream());
        //concat.forEach(s -> System.out.println(s));
         //根据姓名创建Person对象；
        List<String> list = concat.collect(Collectors.toList());

        for (String name : list) {
            Person person = new Person(name);
            System.out.println(person);
        }

    }
}
